package binary;

import lombok.Data;

/**
 * @author ZH
 */
@Data
public class User {
    public static final Integer WEB = 1 << UserEnum.WEB.getCode(); // 1
    public static final Integer APP = 1 << UserEnum.APP.getCode(); //2
    public static final Integer MANGE = 1 << UserEnum.MANGE.getCode(); //4
    private String userName;
    private int platform;
    public String getPlatformName(){
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i <= 2; i++) {
            if ((this.platform & (1 << i)) != 0){
                stringBuilder.append(UserEnum.getMsgByCode(i)).append(" ");
            }
        }
        return stringBuilder.toString();
    }

    public void setPlatform(Integer platform){
        this.platform += platform;
    }

    public final boolean isWeb(){
        return (platform & WEB) != 0;
    }
    public final boolean isApp(){
        return (platform & APP) != 0;
    }
    public final boolean isMange(){
        return (platform & MANGE) != 0;
    }
}
